package com.tanhua.admin.controller;


import com.tanhua.admin.service.DashboardService;
import com.tanhua.model.vo.CountVo;
import com.tanhua.model.vo.CountYearVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/dashboard")
@Slf4j
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    /**
     * 统计数据
     *
     * @return
     */
    @GetMapping("/summary")
    public ResponseEntity summary() {
        CountVo countVo = dashboardService.statistics();
        return ResponseEntity.ok(countVo);
    }

    /**
     * 新增.活跃用户.次日留存率
     *
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity users(@RequestParam("sd") String startTime,
                                @RequestParam("ed") String endTime
            , String type) {
        CountYearVo countYearVo = dashboardService.users(startTime, endTime, type);
        return ResponseEntity.ok(countYearVo);
    }
}
